package com.hnhs.controller;

import com.hnhs.info.ProductStatusUpdate;
import com.hnhs.model.Category;
import com.hnhs.model.CategoryQuery;
import com.hnhs.model.Product;
import com.hnhs.model.ProductQuery;
import com.hnhs.service.CategoryService;
import com.hnhs.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/product")
//@CrossOrigin
public class ProductController {
    @Autowired
    private ProductService service;


    @GetMapping
    public List<Product> select(ProductQuery query){
        return service.select(query);
    }

    @PostMapping
    public Integer insert(@RequestBody Product product){
        return  service.insert(product);
    }
    @PutMapping
    public Integer update(@RequestBody Product product){
        return  service.update(product);
    }
//    @DeleteMapping
//    public Integer delete(Integer id){
//        return  service.delete(id);
//    }
    @PatchMapping
    public Integer updateStatus(@RequestBody ProductStatusUpdate update){
        return service.updateStatus(update);
    }
}
